<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2017/6/29
 * Time: 20:05
 */

$zip = new ZipArchive();
$filename = "./test.zip";
if ($zip->open($filename, ZipArchive::CREATE)!==TRUE) {
	exit("cannot open <$filename>\n");
}

$zip->addFromString(date("Y-d-m H:i:s",time()).".txt" ,
	file_get_contents(__FILE__));
$zip->addFile(__FILE__,basename(__FILE__));
$zip->addEmptyDir(basename(__DIR__));
$zip->setPassword(8888);
$zip->setCommentIndex(1,"one");
$zip->filename="zip.zip";
$zip->setArchiveComment("测试压缩归档-test");
$zip->renameName("1.php","2.php");
echo "numfiles: " . $zip->numFiles . "\n";
echo "status:" . $zip->status . "\n";
$zip->close();